using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class MenuUIManager : MonoBehaviour
{
    // Start is called before the first frame update
    public Button buttonStart;
    public Button buttonQuit;

    void Start()
    {
        buttonStart.onClick.AddListener(OnButtonStartClick);
        buttonQuit.onClick.AddListener(OnButtonQuitClick);
    }

    // Update is called once per frame
    void Update()
    {
    }

    void OnButtonStartClick()
    {
        AudioManager.Instance.PlayButtonAudio();
        // 禁用按钮，防止重复点击
        buttonStart.interactable = false;
        // 延迟调用场景切换方法
        Invoke("LoadNextScene", AudioManager.Instance.buttonClinkAudio.clip.length);
    }

    void LoadNextScene()
    {
        SceneManager.LoadScene("Game");
    }

    void OnButtonQuitClick()
    {
        AudioManager.Instance.PlayButtonAudio();
        Application.Quit();
    }
}